<?php
class Setting extends AppModel{
    public $useTable  = 'setting';
    
    function delAll()
    {
        $sql = "DELETE FROM setting";
        return $this->query($sql);
    }
    
    function add($data = array())
    {
        return $this->save($data);
    }
    
    
    function edit_url_image($url = null)
    {
        $path_folder_upload = Configure::read('path_folder_upload');
        $arr_url_img = explode('/', $url);
        $name_img = end($arr_url_img);
        $i = 0;
        if($name_img != 'no-image.jpg')
        {
            $url_folder = "";
            foreach($arr_url_img as $key => $value)
            {
                if($i == 1 && $value != $name_img)
                {
                    $url_folder .= $value.'/';
                }
                if($value == 'upload')
                    $i = 1;
            }
            return $path_folder_upload . $url_folder . $name_img;
        }
        else
        {
            return "";
        }
    }
}